<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> 
<head>
<%@ include file="../../include/easyui.jsp" %>
<%@ include file="../../include/pGrid.jsp" %>
<title>单项工程管理</title>
<script>
	$(function(){
		var userId = '${SESSION_USER.user.id}';
		var gridParam = {
			sort:"createTime",
			order:"desc",
			queryParams:{
				rightControl: true //启用数据权限控制
			},
			columns : [[ 
			     {field: 'pNo', title: '工程路段编号', width: 130} 
		    	,{field: 'pRoad', title: '工程段落', width: 270}
		    	,{field: 'status', title: '项目状态', width: 120}
		    	,{field: 'pType', title: '专业类别', width: 80}
		    	,{field: 'contractNo', title: '订单编号', width: 240}
		    	,{field: 'pName', title: '项目名称', width: 250}
		    	,{field: 'budgetMoney', title: '立项预算', width: 90}
		    	,{field: 'actualMoney', title: '完工预算', width: 90}
		    	,{field: 'designLength', title: '设计长度', width: 80}
		    	,{field: 'pm', title: '项目经理', width: 100}
		    	,{field: 'marketManager', title: '市场负责人', width: 100}
		    	,{field: 'constructionUnit', title: '建设单位', width: 200}
		    	,{field: 'designUnit', title: '设计单位', width: 120}
		    	,{field: 'operator', title: '运营商', width: 120}
		    	,{field: 'ppm', title: '工程经理', width: 120}
		    	,{field: 'orgNo', title: '所属机构', width: 180,formatter: function(value,row,index){
					return (value || '') + '-' + (row.orgNoName|| '') ;
				}}
		    	//,{field: 'department', title: '所属项目部', width: 120}
		    	,{field: 'pCreateDate', title: '订单日期', width: 120}
		    	,{field: 'subpackage', title: '是否分包', width: 120}
		    	,{field: 'subpackageScale', title: '分包比例', width: 120}
		    	,{field: 'region', title: '区域', width: 120}
		    	,{field: 'priority', title: '优先级', width: 120}
		    	/*,{field: 'flowName', title: '流程模板', width: 200}*/
		    	,{field : 'remark',width : 150,title: '备注'}
		    	,{field: 'createTime', title: '创建时间', width: 130}
		    	,{field: 'createrName', title: '创建人', width: 120}
			]],
			onSelect:function(index, row){
				var $btn = $("a[motion_code=09]");
				if(row.status=='初始化录入'){
					$btn.linkbutton('enable'); return ;
				}else{
					$btn.linkbutton('disable'); return ;
				}
			},
			onLoadSuccess: function(){
				p.tooltip([ 'pRoad', 'contractNo', 'pName' ,'constructionUnit']);
			}
		};
		p.dataGrid = $(p.dataGrid).datagrid( $.extend({}, p.dataGridParam,gridParam));
		/*事件响应*/
		$("#toolbar .easyui-linkbutton").on("click", function() {
			var motion_code = $(this).attr("motion_code");
			var flag = $(this).hasClass("l-btn-disabled");
			if(flag) return ;
			p.btnOneClick($(this));
			switch (motion_code) {
				case "01":
					p.gridAdd({ title : "立项管理新增", width : 850, height : 430 ,autoMax:true});
					break;
				case "02":
					p.gridModify({ title : "立项管理编辑", width : 850, height : 430 ,autoMax:true});
					break;
				case "03":
					p.gridDelete({ msg:"您确认删除当前选中用户记录？" });
					break;
				case "04":
					p.gridView({title : "立项管理查看", width : 850, height : 430 ,autoMax:true});		
					break;
				case "05":
					p.gridQuery();
					break;
				case "06":
					var rows = p.dataGrid.datagrid('getSelections'), len = rows.length || 0 ;
					if(len<=0){
						p.tip({ msg : '请选择一条记录配置！' }); return;
					} 
					p.gridView({ title : "清单配置", width : 600, height : 400,autoMax:true,href:"/console/theLibrary/rewrite/detailedList?tid="+rows[0].pNo });
					break;
				case "07":
					p.down({filename:'立项管理'});
					break;
				case "09":
					var row = p.getSelection('请先选定一条记录再处理!');
					if(row){
						if(row.status!='初始化录入'){
							p.tip({msg: '此流程已经启动，无法重复启动！'});  return ;
						}
						$.messager.confirm('确认对话框', '您确认启动工程路段编号为【'+ row.pNo +'】的流程处理吗？', function(r){if (r){
							$.getJSON("/console/activiti/startProjectProcess", {projectId:row.id} ,function(res){
								if(res.flag){
									p.tip({msg: '流程启动成功！'});  
									p.gridQuery();
								}else{
									p.tip({msg:  res.msg});  
								}
				        	 });
						}});
						/*var buttons = [{
							text : "驳回", iconCls : "icon-back", handler : function() {
								$.getJSON("/console/project/rewrite/back/"+row.id, {} ,function(res){
									if(res.flag){
										p.tip({msg: '驳回成功！'});  
									}else{
										p.tip({msg:  res.msg});  
									}
					        	 });
								p.dialog.dialog('close');
							}
						},p.buttons.submit,p.buttons.close];
						
						if(row.startFlag==0){ buttons.shift(); } //新建环节无驳回按钮
						var url = '/console/project/rewrite/actionPage/'+ row.id + '?pid='+  row.id +'&pNo='+ row.pNo;
						p.gridModify({href:url, title : "【"+row.pRoad+  "】立项流程处理", width : 850, height : 430 ,autoMax:true,
							buttons: buttons
						});*/
					}
					break;
				case "10":
					var row = p.getSelection('请先选定一条记录再查看详情!');
					if(row){
						p.gridOpt({href:'/console/project/config?id='+ row.id + '&pNo='+ row.pNo, title : "更多项目详情", width : 850, height : 430 ,autoMax:true});
					}
					break;
				case "14":
					var row = p.getSelection('请先选定一条记录再复制!');
					if(row){
						row = $.extend(row,{ id:'',pNo:'',attachment:'',url:'',remark:'' });
						p.gridAdd({ title : '立项记录复制', width : 850, height : 430 ,data: row,autoMax:true});
					}
					break;
				case "19":
						p.gridAdd({href:'/console/project/import', title : "项目数据导入", width : 550, height : 330 });
					break;
				case "20":
					var row = p.getSelection('请先选定一条记录再流程状态查看!');
					if(row){
						p.gridOpt({href:'/console/project/rewrite/flow?id='+ row.id + '&pNo='+ row.pNo, title : "单项工程流程详情", width : 850, height : 430 ,autoMax:true});
					}
					break;
				default:
					break;
				}
		});
	});
</script>
</head>
<body class="easyui-layout">
	<!-- 但行高度33px，多行时 33乘以行数  -->
	<div data-options="region:'north',split:false,border:false" style="height:auto;">
		<div class="easyui-panel" data-options="fit:true,border:false">
			<!-- 查询条件表单，根据配置进行替换  -->
			<form id="queryForm" >
			 <input type="hidden" name="className" value="com.fs.jzzn.pojo.Project" />
			 <div style="margin-top:5px;margin-left:10px;float:left;">
			  	<input class="easyui-textbox" name="pNo" style="width:240px;" data-options="label:'路段编号:',required:false,labelWidth:65,prompt:'路段编号关键词' " />
				<input type="hidden" name="pNo_searchType" value="like" />
			 </div>
			 <div style="margin-top:5px;margin-left:10px;float:left;">
			  	<input class="easyui-textbox" name="pRoad" style="width:240px;" data-options="label:'工程段落:',required:false,labelWidth:65,prompt:'工程段落关键词' " />
				<input type="hidden" name="pRoad_searchType" value="like" />
			 </div>
			 
			 <div style="margin-top:5px;margin-left:10px;float:left;">
			  	<select class="easyui-combobox" name="status" style="width:240px;" data-options="label:'项目状态:' ,labelWidth:65,prompt:'区域关键词' " 
					url="/console/combobox?valueField=dicName&textField=dicName&modleName=dictionary&pCode=A4&pCode_searchType=eq" >
			    </select>
				<input type="hidden" name="status_searchType" value="like" />
			 </div>
			 
			 <div style="margin-top:5px;margin-left:10px;float:left;">
			  	<input class="easyui-textbox" name="contractNo" style="width:240px;" data-options="label:'订单编号:',required:false,labelWidth:65,prompt:'订单编号关键词' " />
				<input type="hidden" name="contractNo_searchType" value="like" />
			 </div>
			 <div style="margin-top:5px;margin-left:10px;float:left;">
			  <input class="easyui-textbox" name="pName" style="width:240px;" data-options="label:'项目名称:',required:false,labelWidth:65,prompt:'项目名称关键词' " />
			<input type="hidden" name="pName_searchType" value="like" />
			 </div>
			 <div style="margin-top:5px;margin-left:10px;float:left;">
			  	<select class="easyui-combobox" name="region" style="width:240px;" data-options="label:'区域:' ,labelWidth:65,prompt:'区域关键词' " 
					url="/console/combobox?valueField=dicName&textField=dicName&modleName=dictionary&pCode=B5&pCode_searchType=eq" >
			    </select>
				<input type="hidden" name="region_searchType" value="like" />
			 </div>
			 
			 <div  style="margin-top:5px;margin-left:10px;float:left;">
				 	<input type="hidden" name="orgNo_searchType" value="like" />
				 	<select class="easyui-combotreegrid" id="orgNo_tree" name="orgNo" style="width:240px;" data-options="label:'所属机构:',panelWidth:300,labelWidth:60,
			           	prompt:'请选择组织机构',
			           	idField: 'orgNo', 
						treeField: 'orgName',
						sortName:'orgOrder',
						icons: [{
							iconCls:'icon-remove',
							handler: function(e){
								$(e.data.target).textbox('setValue', '');
							}
						}],
						iconAlign:'right',
						textField:'orgName',
						onSelect:function(row){
							$('#orgNo_tree').combogrid('setText', row.orgName);
						},
						sortOrder:'asc',
			            url:'/console/com.fs.base.pojo.Org/list', 
			            queryParams:{isTreeGrid:'true', treeId:'id', treePid:'parentId' },
			            columns:[[    
			                {field:'orgName',			width:250,	title:'组织名称' }
			            ]]"></select>
				 </div>
			 	<div class="fItem">
			  		<input class="easyui-combobox" name="createrId" style="width:240px;" url="/console/combobox?valueField=id&textField=nickName&modleName=user" data-options="label:'创建人:',required:false" />
			  		<input type="hidden" name="createrId_searchType" value="eq" />
			 	</div>
			 	
			 	<div class="fItem">
				 	<input class="easyui-datebox" style="width:240px;" name="createTime" data-options="label:'开始日期:',required:false" />
				 	<input type="hidden" name="createTime_searchType" value="between" />
				 	<input type="hidden" name="createTime_format" value="date" />
				</div>
				<div class="fItem">
				 	<input class="easyui-datebox" style="width:240px;" name="createTime" data-options="label:'截至日期:',required:false" />
				</div>
			</form>
		</div>
	</div>  

	<!-- 工具栏按钮 -->
	<div id="toolbar" class="easyui-panel" style="padding:3px;"></div>
	
	<!-- 表格 -->
	<div region="center" border="false">
		<table id="dataGrid"></table>
	</div>
</body>
</html>